﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>ChangeDept</title>
    <link href="~/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <link href="~/lib/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
    <link href="~/lib/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
    <link href="~/Content/css/common.css" rel="stylesheet" type="text/css" />
    <script src="~/lib/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>
    <script src="~/lib/ligerUI/js/ligerui.all.js"></script>
    <script src="~/Scripts/common.js"></script>
    <script>
        $(function () {
            $("#departmentCode").ligerComboBox({
                width: 210,
                cancelable: false,
                url: "/Home/GetDepartmentList?ram" + Math.random(),
                valueField: "value",
                textField: "text",
                valueFieldID: 'hdnDepartmentCode',
                onSuccess: function (data) {
                    $("#departmentCode").ligerComboBox().setValue($("#hdnCurrDepCode").val());
                }
            });
        });

        function save() {
            var code = $("#hdnDepartmentCode").val();
            var name = $("#departmentCode").ligerComboBox().getText();
            $.ajax({
                url: "/Home/ChangeDeptSave",
                type: "post",
                data: {
                    code: code,
                    name: name
                },
                success: function (r) {
                    var r = $.parseJSON(r);
                    if (r.Result == 1) {
                        parent.$("#lblCurrDepName").text(name);
                        parent.$("#userinfo").click();
                        closeDialog();
                    }
                    else if (r.Result == 0) {
                        $.ligerDialog.error(r.Body);
                    }
                    else {
                        $.ligerDialog.error("程序错误");
                    }
                },
                error: function () {
                    $.ligerDialog.error("程序错误");
                }
            });
        }
    </script>
</head>
<body>
    <div style="margin:10px;">
        <input type="text" id="departmentCode" />
    </div>
    <div style="margin-top:150px; text-align:center;">
        <input id="btnSave" type="button" value="确定" class="l-button" onclick="save();" />
    </div>
    <input type="hidden" id="hdnCurrDepCode" value="@(ViewBag.CurrDepCode)" />
</body>
</html>
